package com.zhuiyun.project.api.tag.controller;

import com.zhuiyun.project.api.tag.entity.Tag;
import com.zhuiyun.project.api.tag.entity.TagRequest;
import com.zhuiyun.project.api.tag.model.TagModel;
import com.zhuiyun.project.api.tag.service.TagService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName TagController
 * @Description TODO
 * @Author XMY
 * @Date 2023/12/13 16:41
 **/
@RestController
@RequestMapping("tag")
@Api(tags = "个性标签管理")
public class TagController {
    @Autowired
    private TagService tagService;
    /**
     * @Author XMY
     * @Description 获取个性标签
     * @Date 2023/12/12 14:27
     * @Return
     */
    @GetMapping("/getTagList")
    @ApiOperation(value = "用户个性标签")
    public CommonResult getTagList(){
        List<Tag> tagList = tagService.getTagList();
        return CommonResult.ok(tagList);
    }
    /**
    * @Author XMY
    * @Description 新增用户个性标签
    * @Date 2023/12/14 9:31
    * @Return
    * @param request
    */
    @PostMapping("/savaTag")
    @ApiOperation(value = "新增用户个性标签")
    public CommonResult savaTag(@RequestBody TagRequest request)throws CommonException {
        return tagService.savaTag(request);
    }
    /**
    * @Author XMY
    * @Description 新增用户个性标签
    * @Date 2023/12/14 9:36
    * @Return
    * @param tagModel
    */
    @PostMapping("/insertTag")
    @ApiOperation(value = "新增用户个性标签")
    public CommonResult insertTag(@RequestBody TagModel tagModel) throws CommonException{
        return tagService.insertTag(tagModel);
    }
}
